package performance;

//start extract HelloWorldBenchmark
public class HelloWorldBenchmark {
    public static double aDouble = 123456789.0;
    public static void main(String args[]) {
	
	int numberOfIterations = 15000;
	
	// Loop to measure the overhead
	long time0 = System.currentTimeMillis();
	for ( int j = 0; j < numberOfIterations; j++ ) { 
	    aDouble /= 1.000001;
	}
	long time1 = System.currentTimeMillis();
	
	aDouble = 123456789.0;
	System.out.println("Hello world!");

	long time2 = System.currentTimeMillis();
	for ( int j = 0; j < numberOfIterations; j++ ) {
	    aDouble /= 1.000001;
	    System.out.println("Hello world!");
	}
	long time3 = System.currentTimeMillis();
		
	double timeForOverheadLoop = (time1 - time0);
	double timeForHelloWorld = (time3 - time2) - timeForOverheadLoop;
	System.out.println( "HelloWorldBenchmark: " + timeForOverheadLoop 
			    + " milliseconds for basic loop." );
	System.out.println( "HelloWorldBenchmark: " + timeForHelloWorld 
			    + " milliseconds for " + numberOfIterations 
			    + " iterations." );
	System.out.println( "HelloWorldBenchmark: " 
			    + (timeForHelloWorld/numberOfIterations) 
			    + " milliseconds per print command" );
    }
}
//stop extract HelloWorldBenchmark
